package server;

import java.io.Serializable;

public class ImageUpload implements Serializable {
	private String imageTitle, imageDescription, 
				   imageKeywords, imageDimension, 
				   imageBitDepth, imageFileSize,
				   imageCompressionLevel, royaltyFree,
				   originalFilePath, compressedFilePath;
	
	private byte[] originalImage;
	private byte[] compressedImage;
	
	public ImageUpload(String s1, String s2, String s3, String s4, String s5, String s6, String s7, String s8, byte[] image, byte[] compressed){
		imageTitle = s1;
		imageDescription = s2;
		imageKeywords = s3;
		imageDimension = s4;
		imageBitDepth = s5;
		imageFileSize = s6;
		imageCompressionLevel = s7;
		royaltyFree = s8;
		
		originalFilePath = this.toString() + (Math.random() * 1000) + imageTitle + "Original.jpg";
		compressedFilePath = this.toString() + (Math.random() * 1000) + imageTitle + "Compressed.jpg";
		
		originalImage = image;
		compressedImage = compressed;
	}
	
	public String getCompressedFileName(){
		return compressedFilePath;
	}
	
	public String getOriginalFileName(){
		return originalFilePath;
	}
	
	public byte[] getOriginalImage(){
		return originalImage;
	}
	
	public byte[] getCompressedImage(){
		return compressedImage;
	}
	
	/** This function returns a string which inserts a record of this image into the SQL database */
	public String insert(){
		return "INSERT INTO images VALUES (NULL, '" + imageTitle + "', '" + imageDescription + "', '" + imageKeywords + "', '" + imageDimension+ "',"+ imageBitDepth + ", " + imageFileSize + "," + imageCompressionLevel + "," + royaltyFree + ", '" + getOriginalFileName() + "','" + getCompressedFileName() + "')";
	}
}
